package dragon.core.util;

import dragon.core.io.FileHandler;

/**
 * 文件路径
 */
public class FilePath {

	/**
	 * 文件路径分隔符
	 */
	public static String separator = System.getProperty("file.separator");

	/**
	 * Web根目录
	 */
	public static String webRoot = "";

	/*-------------------------------------data-------------------------------------------------------*/

	/**
	 * data 目录
	 */
	public static String DATA = webRoot + "data" + separator;

	/**
	 * 索引根目录
	 */
	public static String INDEX = DATA + "index" + separator;

	/**
	 * 系统参数序列化文件路径
	 */
	public static String PARAMETERS_SERIALIZEDFILE = DATA + "parameters.ser";

	/**
	 * 公告附件目录
	 */
	public static String BULLETIN_ATTACHMENT = DATA + "b" + separator;
	/**
	 * 公告附件临时目录
	 */
	public static String BULLETIN_ATTACHMENT_TEMP = BULLETIN_ATTACHMENT + "temp" + separator;

	/**
	 * 模型目录
	 */
	public static String MODEL = DATA + "model" + separator;

	/**
	 * 数据模型目录
	 */
	public static String MODEL_TABLE = MODEL + "table" + separator;

	/**
	 * 业务模型目录
	 */
	public static String MODEL_BIZOBJECT = MODEL + "bizobject" + separator;

	/**
	 * 字段模板目录
	 */
	public static String MODEL_FIELDTEMPLATE = MODEL + "fieldtemplate" + separator;

	/**
	 * 业务文件上传目录
	 */
	public static String FILEUPLOAD = DATA + "upload" + separator;
	/*-------------------------------------res-------------------------------------------------------*/

	/**
	 * 资源目录
	 */
	public static String RES = webRoot + "res" + separator;

	/**
	 * 公告资源目录
	 */
	public static String RES_B = RES + "b" + separator;

	/*-------------------------------------配置文件-------------------------------------------------------*/

	public static String webappxml = FileHandler.getClassRootPath() + "webapp.xml";

	/**
	 * 设置webapp根路径
	 * 
	 * @param path
	 */
	public static void setWebRoot(String path) {
		webRoot = path;

		if (!webRoot.endsWith(separator)) {
			webRoot += separator;
		}

		DATA = webRoot + "data" + separator;

		INDEX = DATA + "index" + separator;

		PARAMETERS_SERIALIZEDFILE = DATA + "parameters.ser";

		BULLETIN_ATTACHMENT = DATA + "b" + separator;
		BULLETIN_ATTACHMENT_TEMP = BULLETIN_ATTACHMENT + "temp" + separator;

		MODEL = DATA + "model" + separator;
		MODEL_TABLE = MODEL + "table" + separator;
		MODEL_BIZOBJECT = MODEL + "bizobject" + separator;
		MODEL_FIELDTEMPLATE = MODEL + "fieldtemplate" + separator;

		FILEUPLOAD = DATA + "upload" + separator;

		RES = webRoot + "res" + separator;
		RES_B = RES + "b" + separator;

	}

}
